package com.jwsoft.manager.core.gateway.controller;

import com.bifang.engine.protect.core.annotation.NoSignCrypto;
import com.jwsoft.manager.common.vo.eduHousehold.EduHouseholdVO;
import com.jwsoft.manager.common.vo.eduHouseholdOffline.EduHouseholdOfflineVO;
import com.jwsoft.manager.common.vo.eduLivePlace.EduLivePlaceVO;
import com.jwsoft.manager.core.dao.model.EduLivePlace;
import com.jwsoft.manager.core.integration.EduLivePlaceOfflineIntegration;
import com.jwsoft.manager.common.vo.eduLivePlaceOffline.EduLivePlaceOfflineVO;
import com.jwsoft.manager.common.vo.eduLivePlaceOffline.EduLivePlaceOfflineKeyVO;
import com.jwsoft.manager.common.vo.eduLivePlaceOffline.EduLivePlaceOfflineQueryVO;
import com.github.pagehelper.PageInfo;
import com.bifang.engine.assistant.core.domain.AppResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RestController;
import com.bifang.engine.protect.core.annotation.Idempotent;
import org.springframework.validation.annotation.Validated;
import com.bifang.assistant.common.constants.Validators;

/**
 * 线下居住证新增网关
 *
 * @author wangt
 * @since 2024-06-06
 */
@RestController
@RequestMapping(value = "/doc/api")
@Tag(name = "线下居住证新增", description = "线下居住证新增")
public class EduLivePlaceOfflineController {

    @Autowired
    public EduLivePlaceOfflineIntegration eduLivePlaceOfflineIntegration;

    @Operation(summary = "线下居住证新增分页查询",description = "线下居住证新增分页查询")
    @PostMapping(value = "/eduLivePlaceOffline0001", produces = "application/json;charset=UTF-8")
    public AppResponse<PageInfo<EduLivePlaceOfflineVO>> getList(@RequestBody @Validated EduLivePlaceOfflineQueryVO vo) {
        return AppResponse.successData(eduLivePlaceOfflineIntegration.getList(vo));
    }

    @Operation(summary = "线下居住证新增根据主键查询详情",description = "线下居住证新增根据主键查询详情")
    @PostMapping(value = "/eduLivePlaceOffline0002", produces = "application/json;charset=UTF-8")
    public AppResponse<EduLivePlaceOfflineVO> getById(@RequestBody @Validated EduLivePlaceOfflineKeyVO vo) {
        return AppResponse.successData(eduLivePlaceOfflineIntegration.getById(vo));
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "线下居住证新增新增",description = "线下居住证新增新增")
    @PostMapping(value = "/eduLivePlaceOffline0004", produces = "application/json;charset=UTF-8")
    public AppResponse<EduLivePlaceOfflineVO> add(@RequestBody @Validated(value = {Validators.Add.class}) EduLivePlaceOfflineVO vo) {
        return AppResponse.successData(eduLivePlaceOfflineIntegration.add(vo));
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "线下居住证新增修改",description = "线下居住证新增修改")
    @PostMapping(value = "/eduLivePlaceOffline0005", produces = "application/json;charset=UTF-8")
    public AppResponse<EduLivePlaceOfflineVO> edit(@RequestBody @Validated(value = {Validators.Edit.class}) EduLivePlaceOfflineVO vo) {
        return AppResponse.successData(eduLivePlaceOfflineIntegration.edit(vo));
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "线下居住证新增删除",description = "线下居住证新增删除")
    @PostMapping(value = "/eduLivePlaceOffline0006", produces = "application/json;charset=UTF-8")
    public AppResponse del(@RequestBody @Validated EduLivePlaceOfflineKeyVO vo) {
        eduLivePlaceOfflineIntegration.del(vo);
        return AppResponse.successMsg("删除成功！");
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "线下居住证登记保存",description = "线下居住证登记保存")
    @PostMapping(value = "/eduLivePlaceOffline0010", produces = "application/json;charset=UTF-8")
    @NoSignCrypto
    public AppResponse<EduLivePlaceVO> savePre(@RequestBody @Validated(value = {Validators.Add.class}) EduLivePlaceOfflineVO vo) {
        eduLivePlaceOfflineIntegration.saveOffline(vo);
        return AppResponse.successMsg("操作成功");
    }
}
